package com.hopes.bizz.close.gis.controller;

import com.hopes.bizz.close.common.constant.GisRequestEnums;
import com.hopes.bizz.close.gis.service.ClosedInOutService;
import com.hopes.boss.common.core.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

/**
 * 危险品运输车辆
 *
 * @author pig
 * @date 2023-10-24 19:40:58
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/access")
@Tag(description = "access", name = "封闭化管理一张图（出入园管理）")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class ClosedInOutController {


    private final ClosedInOutService closedInOutService;

    /**
     * 出入园管理 （人员）
     */
    @Operation(summary = "人员管理", description = "人员管理")
    @GetMapping("/person/{type}")
    public R queryPerson(@PathVariable("type") GisRequestEnums.GisCalEnum gisCalEnum) {
        return R.ok(closedInOutService.queryPerson(gisCalEnum));
    }

    @Operation(summary = "人员管理", description = "人员管理")
    @GetMapping("/personChart")
    public R queryPersonChart(@RequestParam("beginTime")String beginTime, @RequestParam("endTime") String endTime) {
        return R.ok(closedInOutService.queryPersonChart(beginTime, endTime));
    }

    /**
     * 出入园管理（危化品车辆）
     */
    @Operation(summary = "危化品车辆", description = "危化品车辆")
    @GetMapping("/hazardCar/{type}")
    public R queryHazardCar(@PathVariable("type") GisRequestEnums.GisCalEnum gisCalEnum) {
        return R.ok(closedInOutService.queryHazardCar(gisCalEnum));
    }


    @Operation(summary = "危化品车辆", description = "危化品车辆")
    @GetMapping("/hazardCarChart")
    public R queryHazardCarChart(@RequestParam("beginTime")String beginTime, @RequestParam("endTime") String endTime) {
        return R.ok(closedInOutService.queryGeneralHazardCarChart(GisRequestEnums.GenHazardEnum.HAZARD, beginTime, endTime));
    }

    /**
     * 出入园管理（普通车辆）
     */
    @Operation(summary = "普通车辆", description = "普通车辆")
    @GetMapping("/generalCar/{type}")
    public R queryGeneralCar(@PathVariable("type") GisRequestEnums.GisCalEnum gisCalEnum) {
        return R.ok(closedInOutService.queryGeneralCar(gisCalEnum));
    }

    /**
     * 出入园管理（普通车辆）图表
     * @param beginTime  开始时间
     * @param endTime    截止时间
     * @return           返回值
     */
    @Operation(summary = "普通车辆", description = "普通车辆")
    @GetMapping("/generalCarChart")
    public R queryGeneralCarChart(@RequestParam("beginTime")String beginTime, @RequestParam("endTime") String endTime) {
        return R.ok(closedInOutService.queryGeneralHazardCarChart(GisRequestEnums.GenHazardEnum.GENERAL, beginTime, endTime));
    }


    /**
     * 卡口车辆统计
     * @param gisCalEnum  统计纬度
     * @return            返回值
     */
    @Operation(summary = "卡口车辆统计", description = "卡口车辆统计")
    @GetMapping("/gateCar/{type}")
    public R queryGateCar(@PathVariable("type") GisRequestEnums.GisCalEnum gisCalEnum) {
        return R.ok(closedInOutService.queryGateCar(gisCalEnum));
    }

    /**
     * 多卡口车辆统计图表
     * @param beginTime  开始时间
     * @param endTime    截止时间
     * @return           返回值
     */
    @Operation(summary = "多卡口车辆统计图表", description = "多卡口车辆统计图表")
    @GetMapping("/multiGateCarChart")
    public R queryMultiGateCarChart(@RequestParam("beginTime")String beginTime, @RequestParam("endTime") String endTime) {
        return R.ok(closedInOutService.queryMultiGateCarChart(beginTime, endTime));
    }

    /**
     * 单卡口车辆进出统计图表
     * @param beginTime   开始时间
     * @param endTime     截止时间
     * @return
     */
    @Operation(summary = "单卡口车辆统计图表", description = "单卡口车辆统计图表")
    @GetMapping("/singleGateCarChart")
    public R querySingleGateCarChart(@RequestParam("gateId") Long gateId, @RequestParam("beginTime") String beginTime, @RequestParam("endTime") String endTime) {
        return R.ok(closedInOutService.querySingleGateCarChart(gateId, beginTime, endTime));
    }

    /**
     * 入园统计
     * @param gisCalEnum  统计纬度
     * @return            统计结果
     */
    @Operation(summary = "入园统计", description = "入园统计")
    @GetMapping("/enterPark/{type}")
    public R queryEnterPark(@PathVariable("type") GisRequestEnums.GisCalEnum gisCalEnum) {
        return R.ok(closedInOutService.queryEnterOuterPark(GisRequestEnums.EnterOuterEnum.ENTER, gisCalEnum));
    }

    /**
     * 出园统计
     * @param gisCalEnum   统计纬度
     * @return             统计结果
     */
    @Operation(summary = "出园统计", description = "出园统计")
    @GetMapping("/outerPark/{type}")
    public R queryOuterPark(@PathVariable("type") GisRequestEnums.GisCalEnum gisCalEnum) {
        return R.ok(closedInOutService.queryEnterOuterPark(GisRequestEnums.EnterOuterEnum.OUTER, gisCalEnum));
    }


    @Operation(summary = "出入园统计图表", description = "出入园统计图表")
    @GetMapping("/enterOuterChart")
    public R queryEnterOuterChart(@RequestParam("beginTime")String beginTime, @RequestParam("endTime") String endTime) {
        return R.ok(closedInOutService.queryEnterOuterChart(beginTime, endTime));
    }


}
